package enumdemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @Author 12629
 * @Date 2022/4/4 20:05
 * @Description：
 */
public class TestReflectEnum {

    public static void func() {
        try {
            Class<?> c = Class.forName("enumdemo.TestEnum");

            Constructor<?> constructor = c.getDeclaredConstructor(String.class,int.class,String.class,int.class);
            constructor.setAccessible(true);

            TestEnum testEnum = (TestEnum)constructor.newInstance("草原色",89,"ffa",90);

            System.out.println(testEnum);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

    }

    public static void main(String[] args) {
        func();
    }
}
